<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/23
 * Time: 9:24
 */

namespace app\index\controller;


use Redis\Redis;
use think\Db;

class ManagementInfo extends Common
{
    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @content 请求员工岗位列表
     */
    function getPositionList()
    {
        #查询员工列表
        $staff = Db::table('employee')->field('distinct jobs_info position_title')->where("employee_status != 0 and del_status = 1 and jobs_info != ''")->select();
        if (!empty($staff)) {
            return array('status' => true, 'data' => $staff);
        } else {
            return array('status' => false, 'msg' => array());
        }
    }

    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @content 请求活动列表
     */
    function getActiveList()
    {
        $_where = '';
        $type = input('post.type');
        if (!empty($type)) {
            $_where .= "a.active_type = $type";
        }
        $time = date('Y-m-d H:i:s');
        #查询活动列表
        $active = Db::table('active a')
            ->field('a.id,active_title title,active_type,active_num num,active_end end_time,active_explain `explain` ,active_imgurl img,active_online price,active_biz cost_price')
            ->where("active_putstatus=2 and active_start <= '" . $time . "' and active_end >= '" . $time . "'")
            ->where($_where)
            ->select();
//        dump(Db::table('active a')->getLastSql());
        if (!empty($active)) {
//            foreach ($active as $k => $v) {
//                $active[$k]['img'] = imgUrl($v['img']);
//            }
            return array('status' => true, 'data' => $active);
        } else {
            return array('status' => false, 'data' => array());
        }
    }

    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @content 活动详情
     */
    function activeDetail()
    {
        # 活动id
        $activeId = input('post.id');
        $activeInfo = Db::table('active')
            ->field('id,active_title title,active_num num,active_end end_time,active_explain `explain` ,
            if(locate("http",active_imgurl)=0,CONCAT("' . config('ecarcoo.EcarsImgUrl') . '",active_imgurl) img,
            active_picurl,
            active_online price,active_biz cost_price')
            ->where(array('id' => $activeId))
            ->find();
        # 活动说明
        $activeInfo['explain'] = str_replace(PHP_EOL, '\n', $activeInfo['explain']);
        # 活动轮播图
        if (!empty($activeInfo['active_picurl'])) {
            $activeInfo['active_picurl'] = explode(',', $activeInfo['active_picurl']);
            foreach ($activeInfo['active_picurl'] as $k => $v) {
                if (!preg_match('/(http:\/\/)|(https:\/\/)/i', $v)) {
                    $activeInfo['active_picurl'][$k] = config('ecarcoo.EcarsImgUrl') . $v;
                }
            }
        }
        # 查询活动详情图片
        $activeInfo['active_content'] = Db::table('active_content')->field('content_detail')->where(array('active_id' => $activeId))->value('content_detail');
        if (!empty($activeInfo['active_content'])) {
            $activeInfo['active_content'] = explode(',', $activeInfo['active_content']);
            foreach ($activeInfo['active_content'] as $k => $v) {
                if (!preg_match('/(http:\/\/)|(https:\/\/)/i', $v)) {
                    $activeInfo['active_content'][$k] = config('ecarcoo.EcarsImgUrl') . $v;
                }
            }
        }
        # 查询活动赠送
        $givingInfo = Db::table('active_giving')
            ->field('giving_id,sum(giving_number) `giving_number`,giving_type,giving_price')
            ->where(array('active_id' => $activeId))
            ->group('giving_type,giving_id')
            ->select();
        $giving_info = array();
        if (!empty($givingInfo)) {
            foreach ($givingInfo as $k => $v) {
                $title = getGivingType($v['giving_type'], $v['giving_id']);
                $giving_info[$k]['title'] = $title['title'];
                $giving_info[$k]['number'] = getGivingNumber($v['giving_type'], $v['giving_number']);
                $giving_info[$k]['price'] = $v['giving_price'];
            }
        }
        $activeInfo['giving_info'] = $giving_info;
        return array('status' => true, 'info' => $activeInfo);
    }

    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @content 请求会员列表
     * 注:会员卡列表的方法getLevelPic 需要图片路径 和新图片 找前端ui要    getLevelPic 没改
     */
    function getMemberList()
    {
        #查询会员id
        $info = Db::table('member_level')->field('id,level_title as member_title,level_img member_img,
        convert(coalesce(level_practical,0) ,decimal(10,2)) as price,if(id > 1,\'永久有效\',level_time) end_time,level_practical,giving_integral')->order('id desc')->select();
        foreach ($info as $k => $v) {
            $level_id = $v['id'];
            #获取会员卡图片  mark 为detail 时获取的是详情的页会员卡图片  反之获取的是列表的会员卡图片
//            $info[$k]['member_img'] = imgUrl(getLevelPic($v['id']));
            $info[$k]['member_card'] = imgUrl(getLevelPic($v['id'], 'detail'));

            #限制门店
            $info[$k]['limit'] = '所有门店支持使用';
            #办理可获得积分
            $info[$k]['integral'] = $v['giving_integral'];

            # 查询会员卡特权(会员福利)
            $level_privilege = Db::table('level_content')->field('level_privilege')->where("id = $level_id")->find();
            $level_privilege_id = $level_privilege['level_privilege'];
            $levelPrivilege = Db::table('privilege')->field('privilege_content')->where("id in ($level_privilege_id)")->select();
            if (!empty($levelPrivilege)) {
                $_privilege = array();
                foreach ($levelPrivilege as $lpk => $lpv) {
                    array_push($_privilege, strip_tags($lpv['privilege_content']));
                }
            }
            $info[$k]['welfare'] = $_privilege;

            # 查询会员卡赠送
            $levelGiving = Db::table('setmeal')->where("level_id = $level_id")->select();
            if (!empty($levelGiving)) {
                $givingInfo = array();
                foreach ($levelGiving as $lgk => $lgv) {
                    $_pro = array();
                    $_service = array();
                    $givingInfo[$lgk]['title'] = $lgv['title'];
                    #查询会员赠送
                    $levelGivingDetails = Db::table("level_giving")->where(array("setmeal_id" => $lgv['id']))->select();
                    if (!empty($levelGivingDetails)) {
                        foreach ($levelGivingDetails as $lgdk => $lgdv) {
                            if ($lgdv['giving_type'] == 1) {
                                # 商品赠送
                                if (array_key_exists($lgdv['giving_id'], $_pro)) {
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['num'] = $givingInfo[$lgk]['card'][$lgdv['giving_id']]['num'] + $lgdv['giving_number'];
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['price'] = getsPriceFormat((floatval($_pro[$lgdv['giving_id']]) * $givingInfo[$lgk]['card'][$lgdv['giving_id']]['num']));
                                } else {
                                    $_info = Db::table('biz_pro')->field(" biz_pro_title,biz_pro_online")->where(array("id" => $lgdv['giving_id']))->find();
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['title'] = $_info['biz_pro_title'];
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['num'] = $lgdv['giving_number'];
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['give_time'] = 365;
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['price'] = getsPriceFormat((floatval($_info['biz_pro_online']) * $lgdv['giving_number']));
                                    $_pro[$lgdv['giving_id']] = $_info['biz_pro_online'];
                                }
                            } else {
                                # 服务赠送
                                if (array_key_exists($lgdv['giving_id'], $_service)) {
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['num'] = $givingInfo[$lgk]['card'][$lgdv['giving_id']]['num'] + $lgdv['giving_number'];
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['price'] = getsPriceFormat((floatval($_service[$lgdv['giving_id']]) * $givingInfo[$lgk]['card'][$lgdv['giving_id']]['num']));
                                } else {
                                    #查询服务名称
                                    $_info = Db::table('service')->field('service_title')->where(array('id' => $lgdv['giving_id']))->find();
                                    if (!empty($_info)) {
                                        # 查询最高价格
                                        $_price = Db::table('service_car_mediscount')->field('max(discount) discount')->where(array('service_id' => $lgdv['giving_id']))->find();
                                    }
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['title'] = $_info['service_title'];
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['num'] = $lgdv['giving_number'];
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['give_time'] = 365;
                                    $givingInfo[$lgk]['card'][$lgdv['giving_id']]['price'] = getsPriceFormat((floatval($_price['discount']) * $lgdv['giving_number']));
                                    $_service[$lgdv['giving_id']] = $_price['discount'];
                                }
                            }
                        }
                    }
                }
            }
            if (!empty($givingInfo)) {
                foreach ($givingInfo as $gk => $gv) {
                    if (!empty($gv['card']))
                        $givingInfo[$gk]['card'] = array_values($gv['card']);
                }
            }
            $info[$k]['setmeal'] = $givingInfo;
            # 查询会员特权
            $info[$k]['privilege'] = Db::table('privilege')
                ->field('id,title,privilege_content,privilege_icon icon')
                ->where("find_in_set(id,(select level_privilege from level_content where level_id = " . $v['id'] . "))")
                ->select();
            foreach ($info[$k]['privilege'] as $pk => $pv) {
                $info[$k]['privilege'][$pk]['privilege_content'] = preg_replace("/<p.*?>|<\/p>/is", "", $pv['privilege_content']);
            }
        }
        return array('status' => true, 'data' => $info);
    }

    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @content 请求门店收入(废弃)
     */
    function getCooIncome()
    {
        # 操作标识  1 今日  2 本周 3 本月  其他->指定日期   默认今日
        $mark = input("post.mark");
        # 搜索日期
        $start_time = input('post.start_time');
        $end_time = input('post.end_time');
        if ($mark == 1) {
            #今日
            $_where = "date_format(create_time,'%Y-%m-%d') = '" . date('Y-m-d') . "'";
            $_time = date("Y-m-d") . '~' . date("Y-m-d");
        } elseif ($mark == 2) {
            #本周
            $begin = beginWeek(false);
            $end = endWeek(false);
            $_where = "date(create_time) >= '" . $begin . "' and date(create_time) <= '" . $end . "'";
            $_time = $begin . '~' . $end;
        } elseif ($mark == 3) {
            # 本月
            $_where = "date_format( create_time,'%Y-%m') = '" . date('Y-m') . "'";
            $_time = date("Y-m-01") . '~' . date('Y-m-d');
        } else {
            # 指定日期搜索
            if (empty($mark)) {
                $start_time = date('Y-m-d');
                $end_time = date('Y-m-d');
            }
            $_where = "date(create_time) >= '" . $start_time . "' and date(create_time) <= '" . $end_time . "'";
            $_time = $start_time . '~' . $end_time;
        }
        $pageNum = input('post.page_num') ?? 0;
        $size = input('post.size') ?? 20;
        $limit = $pageNum * $size;
        #查询收入
        $orderNumberArr = array();
        $income = Db::table('biz_settlement')
            ->field('price money,date_format(create_time,\'%Y-%m-%d %H:%i\') time,type typeMark,"平台结算" type,order_number,desposit_status')
            ->where(array('biz_id' => $this->bizId))
            ->where($_where)
            ->limit($limit, $size)
            ->order('create_time desc')
            ->select();
        $platform_income = 0;
        if (!empty($income)) {
            foreach ($income as $k => $v) {
                if ($v['typeMark'] == 1) {
                    if ($v['desposit_status'] == 2) {
                        array_push($orderNumberArr, "'" . $v['order_number'] . "'");
                    } else {
                        unset($income[$k]);
                    }
                } else {
                    $platform_income += $v['money'];
                }
            }
            $income = array_values($income);
        }
        if (!empty($orderNumberArr)) {
            # 平台收入
            $platform = Db::table('order_server os')->where("custommark = 1")
                ->where("os.order_number in (" . implode(',', $orderNumberArr) . ")")->sum('final_settlement');
            # 门店服务
            $store_service = Db::table('order_server os')->where(array('custommark' => 2))
                ->where("os.order_number in (" . implode(',', $orderNumberArr) . ")")->sum('final_settlement');
            # 门店商品
            $store_pro = Db::table('order_biz ob')->where(array('custommark' => 2))
                ->where("ob.order_number in (" . implode(',', $orderNumberArr) . ")")->sum('final_settlement');
        } else {
            $platform = 0;
            $store_pro = 0;
            $store_service = 0;
        }
        $_countIncome = $platform + $store_pro + $store_service + $platform_income;
        return array('status' => true, 'data' => $income, 'chart' => array('platform' => $platform, 'store_service' => $store_service, 'store_pro' => $store_pro, 'member' => $platform_income), 'time' => $_time, 'countIncome' => getsPriceFormat($_countIncome));
    }

    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @content 请求门店收入
     */
    function incomeStatic()
    {
        # 操作标识  1 今日  2 本周 3 本月  其他->指定日期   默认今日
        $mark = input("post.mark");
        # 搜索日期
        $start_time = input('post.start_time');
        $end_time = input('post.end_time');
        $whereTime_range = null;
        if ($mark == 1) {
            #今日
//            $whereTime_op = 'today';
            $_where = "date_format(pay_create,'%Y-%m-%d') = '" . date('Y-m-d') . "'";
            $_time = date("Y/m/d");
        } elseif ($mark == 2) {
            #本周
            $begin = beginWeek(false);
            $end = endWeek(false);
//            $whereTime_op = 'week';
            $_where = "date(pay_create) >= '" . $begin . "' and date(pay_create) <= '" . $end . "'";
            $_time = $begin . '~' . $end;
        } elseif ($mark == 3) {
            # 本月
            $whereTime_op = 'month';
            $_where = "date_format( pay_create,'%Y-%m') = '" . date('Y-m') . "'";
            $_time = date("Y/m/01") . '~' . date('Y/m/d');
        } else {
            # 指定日期搜索
            if (empty($mark)) {
                $start_time = date('Y/m/d');
                $end_time = date('Y/m/d');
            }
//            $whereTime_op = 'between';
//            $whereTime_range = [$start_time, $end_time];
            $_where = "date(pay_create) >= '" . $start_time . "' and date(pay_create) <= '" . $end_time . "'";
            $_time = $start_time . '~' . $end_time;
        }
        #查询收入统计

        # 平台服务
        $platform = Db::table('order_server os')
            ->join('orders o', 'o.order_number=os.order_number', 'left')
            ->join('service s', 's.id=os.server_id', 'left')
            ->where("o.biz_id = " . $this->bizId . " and o.order_status = 5")
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
            ->where($_where)
            ->where("os.custommark = 1 and s.biz_pid = 0")
            ->sum('final_settlement')
            +
            Db::table('order_server os')
                ->join('orders o', 'o.order_number=os.order_number', 'left')
                ->join('service s', 's.id=os.server_id', 'left')
                ->where("o.biz_id = " . $this->bizId . " and o.order_status = 5")
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
                ->where($_where)
                ->where('o.pay_type in (3,4)')
                ->where("os.custommark = 1 and s.biz_pid = 0")
                ->sum('os.price')
        ;
        # 门店服务
        $store_service = Db::table('order_server os')
            ->join('orders o', 'o.order_number=os.order_number', 'left')
            ->join('service s', 's.id=os.server_id', 'left')
            ->where("o.biz_id = " . $this->bizId . " and o.order_status = 5")
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
            ->where($_where)
            ->where('os.custommark = 2 or (os.custommark = 1 and s.biz_pid > 0 and s.add_type = 2)')
            ->sum('final_settlement')
            +
            Db::table('order_server os')
                ->join('orders o', 'o.order_number=os.order_number', 'left')
                ->join('service s', 's.id=os.server_id', 'left')
                ->where("o.biz_id = " . $this->bizId . " and o.order_status = 5")
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
                ->where($_where)
                ->where('o.pay_type in (3,4)')
                ->where('os.custommark = 2 or (os.custommark = 1 and s.biz_pid > 0 and s.add_type = 2)')
                ->sum('os.price')
        ;
        # 门店商品
        $store_pro_s = Db::table('order_server os')
            ->join('orders o', 'o.order_number=os.order_number', 'left')
            ->join('service s', 's.id=os.server_id', 'left')
            ->where("o.biz_id = " . $this->bizId . " and o.order_status = 5")
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
            ->where($_where)
            ->where('os.custommark = 1 and s.biz_pid > 0 and s.add_type = 1')
            ->sum('final_settlement')
            +
            Db::table('order_server os')
                ->join('orders o', 'o.order_number=os.order_number', 'left')
                ->join('service s', 's.id=os.server_id', 'left')
                ->where("o.biz_id = " . $this->bizId . " and o.order_status = 5")
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
                ->where($_where)
                ->where('o.pay_type in (3,4)')
                ->where('os.custommark = 1 and s.biz_pid > 0 and s.add_type = 1')
                ->sum('os.price')
        ;
        $store_pro_b = Db::table('order_biz ob')
            ->join('orders o', 'o.order_number=ob.order_number', 'left')
            ->where("o.biz_id = " . $this->bizId . " and o.order_status = 5")
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
            ->where($_where)
            ->where(array('custommark' => 2))
            ->sum('final_settlement')
            +
            Db::table('order_biz ob')
                ->join('orders o', 'o.order_number=ob.order_number', 'left')
                ->where("o.biz_id = " . $this->bizId . " and o.order_status = 5")
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
                ->where($_where)
                ->where('o.pay_type in (3,4)')
                ->where(array('custommark' => 2))
                ->sum('ob.pro_price')
        ;
        $store_pro = $store_pro_s + $store_pro_b;
        $_countIncome = $platform + $store_pro + $store_service;
        if ($_countIncome > 0) {
            $platform_ratio = $platform / $_countIncome;
            $store_service_ratio = $store_service / $_countIncome;
            $store_pro_ratio = $store_pro / $_countIncome;
        } else {
            $platform_ratio = 0;
            $store_service_ratio = 0;
            $store_pro_ratio = 0;
        }
        # 查询车辆统计
        # 小型车
        $small_car = Db::table('orders o')
            ->where(array('o.biz_id' => $this->bizId, 'o.order_status' => 5, 'o.car_level' => 1))
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
            ->where($_where)
            ->count();
        # 中型车
        $midsize_car = Db::table('orders o')
            ->where(array('o.biz_id' => $this->bizId, 'o.order_status' => 5, 'o.car_level' => 2))
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
            ->where($_where)
            ->count();
        # 大型车
        $large_car = Db::table('orders o')
            ->where(array('o.biz_id' => $this->bizId, 'o.order_status' => 5, 'o.car_level' => 3))
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
            ->where($_where)
            ->count();
        $_countCar = $small_car + $midsize_car + $large_car;
        if ($_countCar > 0) {
            $small_car_ratio = $small_car / $_countCar;
            $midsize_car_ratio = $midsize_car / $_countCar;
            $large_car_ratio = $large_car / $_countCar;
        } else {
            $small_car_ratio = 0;
            $midsize_car_ratio = 0;
            $large_car_ratio = 0;
        }
        # 服务统计(服务次数倒序--5条)(select custom_server_title from customserver cs where cs.id=os.server_id limit 1)
        $serviceStatistics = Db::table('order_server os')
            ->field('count(os.id) num,if(os.custommark=1,os.server_id,0) id_server,
            if(os.custommark=1,(select service_title from service s where s.id=os.server_id limit 1),"自定义服务") title,
            cast(sum(if(o.pay_type in (3,4),price,final_settlement)) AS DECIMAL (11, 2)) price')
            ->join('orders o', 'o.order_number=os.order_number', 'left')
            ->where(array('o.biz_id' => $this->bizId, 'o.order_status' => 5))
//            ->whereTime('pay_create', $whereTime_op, $whereTime_range)
            ->where($_where)
            ->group('id_server')
            ->order("num desc")
            ->limit(5)
            ->select();
        return array('status' => true,
            'chart_income' => array(
                'platform' => getsPriceFormat($platform),
                'platform_ratio' => getsNumFormat($platform_ratio),
                'store_service' => getsPriceFormat($store_service),
                'store_service_ratio' => getsNumFormat($store_service_ratio),
                'store_pro' => getsPriceFormat($store_pro),
                'store_pro_ratio' => getsNumFormat($store_pro_ratio),
            ),
            'chart_car' => array(
                'small_car' => ($small_car),
                'small_car_ratio' => getsNumFormat($small_car_ratio),
                'midsize_car' => ($midsize_car),
                'midsize_car_ratio' => getsNumFormat($midsize_car_ratio),
                'large_car' => ($large_car),
                'large_car_ratio' => getsNumFormat($large_car_ratio)
            ),
            'time' => $_time,
            'countIncome' => getsPriceFormat($_countIncome),
            'countCar' => ($_countCar),
            'serviceStatistics' => $serviceStatistics
        );
    }

    /**
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @content 查看详情
     */
    function incomeStaticSec()
    {
        # 操作标识  1 今日  2 本周 3 本月  其他->指定日期   默认今日
        $mark = input("post.mark");
        # 搜索日期
        $start_time = input('post.start_time');
        $end_time = input('post.end_time');
        $whereTime_range = null;
        if ($mark == 1) {
            #今日
            $whereTime_op = 'd';
        } elseif ($mark == 2) {
            #本周
            $whereTime_op = 'w';
        } elseif ($mark == 3) {
            # 本月
            $whereTime_op = 'm';
        } else {
            # 指定日期搜索
            if (empty($mark)) {
                $start_time = date('Y/m/d');
                $end_time = date('Y/m/d');
            }
            $start_time = date('Y-m-d 00:00:00',strtotime($start_time));
            $end_time = date('Y-m-d 23:59:59',strtotime($end_time));
            $whereTime_op = 'between';
            $whereTime_range = [$start_time, $end_time];
        }
        # 查询详情
        $pageNum = input('post.page_num') ?? 0;
        $size = input('post.size') ?? 20;
        $limit = $pageNum * $size;
        $info = Db::table('biz_settlement')
            ->field('cast(price as decimal(11,2)) price,
            case method 
                when 1 then \'微信支付\'
                when 2 then \'支付宝支付\'
                when 3 then \'银联支付\' 
                when 4 then \'现金支付\'
                when 5 then \'余额支付\'
                when 6 then \'卡券支付\' 
            end pay_type,
            date_format(create_time,"%Y-%m-%d %H:%i") time')
            ->where(array('biz_id' => $this->bizId, 'mark' => 1, 'type' => 1))
            ->whereTime('create_time', $whereTime_op, $whereTime_range)
            ->order('id desc')
            ->limit($limit, $size)
            ->select();
        return array('status' => true, 'info' => $info);
    }
}
